<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">

<title>class AY - RDoc Documentation</title>

<link href="./fonts.css" rel="stylesheet">
<link href="./rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
</script>

<script src="./js/jquery.js"></script>
<script src="./js/navigation.js"></script>
<script src="./js/search_index.js"></script>
<script src="./js/search.js"></script>
<script src="./js/searcher.js"></script>
<script src="./js/darkfish.js"></script>


<body id="top" role="document" class="class">
<nav role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2>
    <a href="./index.html" rel="home">Home</a>
  </h2>

  <div id="table-of-contents-navigation">
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  

  <div id="class-metadata">
    
    <div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  
  <p class="link">Object
  
</div>

    
    
    <!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    
    <li ><a href="#method-c-new">::new</a>
    
    <li ><a href="#method-i-add_item_to_basket">#add_item_to_basket</a>
    
    <li ><a href="#method-i-api_endpoint-3D">#api_endpoint=</a>
    
    <li ><a href="#method-i-app_credentials-3D">#app_credentials=</a>
    
    <li ><a href="#method-i-base_image_url-3D">#base_image_url=</a>
    
    <li ><a href="#method-i-category_manager">#category_manager</a>
    
    <li ><a href="#method-i-fetch_autocomplete">#fetch_autocomplete</a>
    
    <li ><a href="#method-i-fetch_basket">#fetch_basket</a>
    
    <li ><a href="#method-i-fetch_categories_by_ids">#fetch_categories_by_ids</a>
    
    <li ><a href="#method-i-fetch_category_tree">#fetch_category_tree</a>
    
    <li ><a href="#method-i-fetch_child_apps">#fetch_child_apps</a>
    
    <li ><a href="#method-i-fetch_facet">#fetch_facet</a>
    
    <li ><a href="#method-i-fetch_facet_types">#fetch_facet_types</a>
    
    <li ><a href="#method-i-fetch_facets">#fetch_facets</a>
    
    <li ><a href="#method-i-fetch_order">#fetch_order</a>
    
    <li ><a href="#method-i-fetch_product_search">#fetch_product_search</a>
    
    <li ><a href="#method-i-fetch_products_by_eans">#fetch_products_by_eans</a>
    
    <li ><a href="#method-i-fetch_products_by_ids">#fetch_products_by_ids</a>
    
    <li ><a href="#method-i-fetch_spell_correction">#fetch_spell_correction</a>
    
    <li ><a href="#method-i-fetch_suggest">#fetch_suggest</a>
    
    <li ><a href="#method-i-fetch_variants_by_ids">#fetch_variants_by_ids</a>
    
    <li ><a href="#method-i-generate_basket_item_id">#generate_basket_item_id</a>
    
    <li ><a href="#method-i-init_default_factory">#init_default_factory</a>
    
    <li ><a href="#method-i-initiate_order">#initiate_order</a>
    
    <li ><a href="#method-i-java_script_tag">#java_script_tag</a>
    
    <li ><a href="#method-i-java_script_url">#java_script_url</a>
    
    <li ><a href="#method-i-model_factory">#model_factory</a>
    
    <li ><a href="#method-i-product_search_criteria">#product_search_criteria</a>
    
    <li ><a href="#method-i-query">#query</a>
    
    <li ><a href="#method-i-remove_items_from_basket">#remove_items_from_basket</a>
    
    <li ><a href="#method-i-update_basket">#update_basket</a>
    
  </ul>
</div>

  </div>
</nav>

<main role="main" aria-labelledby="class-AY">
  <h1 id="class-AY" class="class">
    class AY
  </h1>

  <section class="description">
    
<p>Provides access to the Collins Frontend Platform. All the public methods
cover a single API query.</p>
<dl class="rdoc-list note-list"><dt>author
<dd>
<p>Collins GmbH &amp; Co KG</p>
</dd></dl>

  </section>

  
  
  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    
    <section class="constants-list">
      <header>
        <h3>Constants</h3>
      </header>
      <dl>
      
        <dt id="API_ENVIRONMENT_LIVE">API_ENVIRONMENT_LIVE
        
        <dd><p>environment-named for api-live</p>
        
      
        <dt id="API_ENVIRONMENT_SANDBOX">API_ENVIRONMENT_SANDBOX
        
        <dd><p>environment-named for api-sandbox</p>
        
      
        <dt id="API_ENVIRONMENT_STAGE">API_ENVIRONMENT_STAGE
        
        <dd><p>environment-named for api-staging</p>
        
      
        <dt id="IMAGE_URL_LIVE">IMAGE_URL_LIVE
        
        <dd><p>url for live</p>
        
      
        <dt id="IMAGE_URL_SANDBOX">IMAGE_URL_SANDBOX
        
        <dd><p>url for the sandbox</p>
        
      
        <dt id="IMAGE_URL_STAGE">IMAGE_URL_STAGE
        
        <dd><p>url for staging</p>
        
      
      </dl>
    </section>
    

    
    <section class="attribute-method-details" class="method-section">
      <header>
        <h3>Attributes</h3>
      </header>

      
      <div id="attribute-i-about_you_client" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">about_you_client</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>the client which performs the api calls</p>
        
        </div>
      </div>
      
      <div id="attribute-i-api_endpoint" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">api_endpoint</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>the endpoint used for api calls</p>
        
        </div>
      </div>
      
      <div id="attribute-i-app_id" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">app_id</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>the app id of the app which should be represented by an instance of <a
href="AY.html">AY</a></p>
        
        </div>
      </div>
      
      <div id="attribute-i-app_password" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">app_password</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>the authentication token from dev-center for the app id</p>
        
        </div>
      </div>
      
      <div id="attribute-i-base_image_url" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">base_image_url</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>the url for getting images</p>
        
        </div>
      </div>
      
      <div id="attribute-i-cache" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">cache</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>the CacheServer</p>
        
        </div>
      </div>
      
      <div id="attribute-i-environment" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">environment</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>the environment which should be used by the app</p>
        
        </div>
      </div>
      
      <div id="attribute-i-logger" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">logger</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>a logger template</p>
        
        </div>
      </div>
      
      <div id="attribute-i-model_factory_instance" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">model_factory_instance</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>the model factory builds model objects based on the api response</p>
        
        </div>
      </div>
      
      <div id="attribute-i-session_id" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">session_id</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>the session id from a user using this app</p>
        
        </div>
      </div>
      
    </section>
    

    
     <section id="public-class-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Class Methods</h3>
       </header>

    
      <div id="method-c-new" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">new</span><span
            class="method-args">( app_id, app_password, session_id = 'SESSION_ID', cache = nil, api_endpoint = API_ENVIRONMENT_LIVE, result_factory = nil, logger = nil )</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>the Constructor for the <a href="AY.html">AY</a> class</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>app_id</code> -&gt; The App-Id of the App</p>
</li><li>
<p><code>app_password</code> -&gt; The Auth-Token of the App</p>
</li><li>
<p><code>session_id</code> -&gt; A String containing the sessionId of the User</p>
</li><li>
<p><code>api_endpoint</code> -&gt; Can be either live or staging</p>
</li><li>
<p><code>resultFactory</code> -&gt; If nil it will use the DefaultModelFactory
with the DefaultFacetManager</p>
</li><li>
<p><code>logger</code> -&gt; Logger-Template</p>
</li><li>
<p><code>cache</code> -&gt; The preferred Caching-Strategy</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="AY.html">AY</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 63</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(
    <span class="ruby-identifier">app_id</span>,
    <span class="ruby-identifier">app_password</span>,
    <span class="ruby-identifier">session_id</span> = <span class="ruby-string">'SESSION_ID'</span>,
    <span class="ruby-identifier">cache</span> = <span class="ruby-keyword">nil</span>,
    <span class="ruby-identifier">api_endpoint</span> = <span class="ruby-constant">API_ENVIRONMENT_LIVE</span>,
    <span class="ruby-identifier">result_factory</span> = <span class="ruby-keyword">nil</span>,
    <span class="ruby-identifier">logger</span> = <span class="ruby-keyword">nil</span>
  )

  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">session_id</span>   = <span class="ruby-identifier">session_id</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">app_id</span>       = <span class="ruby-identifier">app_id</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">app_password</span> = <span class="ruby-identifier">app_password</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">about_you_client</span> = <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Client</span>.<span class="ruby-identifier">new</span>(
    <span class="ruby-identifier">app_id</span>,
    <span class="ruby-identifier">app_password</span>,
    <span class="ruby-identifier">api_endpoint</span>,
    <span class="ruby-identifier">logger</span>
  )

  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">cache</span> = <span class="ruby-identifier">cache</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">result_factory</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">model_factory_instance</span> = <span class="ruby-identifier">result_factory</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">init_default_factory</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">cache</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">api_endpoint</span> <span class="ruby-operator">==</span> <span class="ruby-constant">API_ENVIRONMENT_STAGE</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">base_image_url</span> = (<span class="ruby-constant">IMAGE_URL_STAGE</span>)
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">environment</span> = <span class="ruby-constant">API_ENVIRONMENT_STAGE</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">api_endpoint</span> <span class="ruby-operator">==</span> <span class="ruby-constant">API_ENVIRONMENT_SANDBOX</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">base_image_url</span> = (<span class="ruby-constant">IMAGE_URL_SANDBOX</span>)
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">environment</span> = <span class="ruby-constant">API_ENVIRONMENT_SANDBOX</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">api_endpoint</span> <span class="ruby-operator">==</span> <span class="ruby-constant">API_ENVIRONMENT_LIVE</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">base_image_url</span> = (<span class="ruby-constant">IMAGE_URL_LIVE</span>)
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">environment</span> = <span class="ruby-constant">API_ENVIRONMENT_LIVE</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Instance Methods</h3>
       </header>

    
      <div id="method-i-add_item_to_basket" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">add_item_to_basket</span><span
            class="method-args">(session_id, variant_id, amount = 1)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Adds a single item into the basket. You can specify an amount. Please mind,
that an amount &gt; 1 will result in amount basket positions. So if you
read out the basket again later, it’s your job to merge the positions
again.</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>session_id</code> -&gt; A String containing the sessionId of the User</p>
</li><li>
<p><code>variant_id</code> -&gt; Id of the Variant which should be added to
the basket</p>
</li><li>
<p><code>amount</code> -&gt; The Amount of the Item which should be added to
the basket</p>
</li></ul>
</li><li>
<p><strong>Fails</strong> :</p>
<ul><li>
<p>if the variant id cant be transformed into an Integer</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a
href="AboutYou/SDK/Model/Basket.html">AboutYou::SDK::Model::Basket</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="add_item_to_basket-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 120</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">add_item_to_basket</span>(<span class="ruby-identifier">session_id</span>, <span class="ruby-identifier">variant_id</span>, <span class="ruby-identifier">amount</span> = <span class="ruby-value">1</span>)
  <span class="ruby-identifier">basket</span> = <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">Basket</span>.<span class="ruby-identifier">new</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">variant_id</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Integer</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">variant_id</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">variant_id</span>[<span class="ruby-regexp">/\d/</span>]
      <span class="ruby-identifier">variant_id</span> = <span class="ruby-constant">Integer</span>(<span class="ruby-identifier">variant_id</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">fail</span> <span class="ruby-string">'the variant id must be an integer or string with digits'</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">amount</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">basket</span>.<span class="ruby-identifier">update_item</span>(<span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">Basket</span><span class="ruby-operator">::</span><span class="ruby-constant">BasketItem</span>.<span class="ruby-identifier">new</span>(
        <span class="ruby-identifier">generate_basket_item_id</span>,
        <span class="ruby-identifier">variant_id</span>
    ))
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">update_basket</span>(<span class="ruby-identifier">session_id</span>, <span class="ruby-identifier">basket</span>)
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-api_endpoint-3D" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">api_endpoint=</span><span
            class="method-args">(api_endpoint)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Setter-Method for the api endpoint</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>api_endpoint</code> -&gt; the endpoint can be the string 'stage' or
'live', then the default endpoints will be used or an absolute url</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="api_endpoint-3D-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 562</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">api_endpoint=</span>(<span class="ruby-identifier">api_endpoint</span>)
  <span class="ruby-identifier">about_you_client</span>.<span class="ruby-identifier">api_endpoint</span> = <span class="ruby-identifier">api_endpoint</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-app_credentials-3D" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">app_credentials=</span><span
            class="method-args">(app_id, app_password)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Setter-Method for the app-Credentials</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>app_id</code> -&gt; the id of an app</p>
</li><li>
<p><code>app_password</code> -&gt; the auth-token for the app</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="app_credentials-3D-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 549</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">app_credentials=</span>(<span class="ruby-identifier">app_id</span>, <span class="ruby-identifier">app_password</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">app_id</span>                   = <span class="ruby-identifier">app_id</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">app_password</span>             = <span class="ruby-identifier">app_password</span>
  <span class="ruby-identifier">about_you_client</span>.<span class="ruby-identifier">app_id</span>       = <span class="ruby-identifier">app_id</span>
  <span class="ruby-identifier">about_you_client</span>.<span class="ruby-identifier">app_password</span> = <span class="ruby-identifier">app_password</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-base_image_url-3D" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">base_image_url=</span><span
            class="method-args">(base_image_url = nil)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Setter-Method for the base image url</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>base_image_url</code> -&gt; nil will reset to the default url, false
to get relative urls, otherwise the url prefix</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="base_image_url-3D-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 572</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">base_image_url=</span>(<span class="ruby-identifier">base_image_url</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">base_image_url</span>
    <span class="ruby-ivar">@base_image_url</span> = <span class="ruby-constant">IMAGE_URL_LIVE</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">base_image_url</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
    <span class="ruby-ivar">@base_image_url</span> = <span class="ruby-identifier">base_image_url</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-node">/[#{'/'}]+$/</span>, <span class="ruby-string">''</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-ivar">@base_image_url</span> = <span class="ruby-string">''</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">model_factory</span>.<span class="ruby-identifier">base_image_url</span> = <span class="ruby-ivar">@base_image_url</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-category_manager" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">category_manager</span><span
            class="method-args">(fetch_if_empty = true)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>The Categories will be fetched automatically, if required by any other
fetch method</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>fetchIfEmpty</code> -&gt; defines whether to fetch if empty or not
[optional]</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of AboutYou::SDK::CategoryManager::DefaultCategoryManager</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="category_manager-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 311</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">category_manager</span>(<span class="ruby-identifier">fetch_if_empty</span> = <span class="ruby-keyword">true</span>)
  <span class="ruby-identifier">category_manager</span> = <span class="ruby-identifier">model_factory</span>.<span class="ruby-identifier">category_manager</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">fetch_if_empty</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">category_manager</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">query</span>.<span class="ruby-identifier">require_category_tree</span>.<span class="ruby-identifier">execute_single</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">category_manager</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_autocomplete" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_autocomplete</span><span
            class="method-args">( searchword, limit = 50, types = [ AboutYou::SDK::Model::Autocomplete::TYPE_PRODUCTS, AboutYou::SDK::Model::Autocomplete::TYPE_CATEGORIES ] )</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Returns the result of an auto completion API request. Auto completion
searches for products and categories by a given prefix (searchword).</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>searchword</code> -&gt; The prefix search word to search for</p>
</li><li>
<p><code>limit</code> -&gt; Maximum number of results [optional]</p>
</li><li>
<p><code>types</code> -&gt; Array of types to search for [optional]</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of AboutYou::SDK::Model::Automcomplete</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_autocomplete-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 218</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_autocomplete</span>(
  <span class="ruby-identifier">searchword</span>,
  <span class="ruby-identifier">limit</span> = <span class="ruby-value">50</span>,
  <span class="ruby-identifier">types</span> = [
    <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">Autocomplete</span><span class="ruby-operator">::</span><span class="ruby-constant">TYPE_PRODUCTS</span>,
    <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">Autocomplete</span><span class="ruby-operator">::</span><span class="ruby-constant">TYPE_CATEGORIES</span>
  ]
)
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">fetch_autocomplete</span>(<span class="ruby-identifier">searchword</span>, <span class="ruby-identifier">limit</span>, <span class="ruby-identifier">types</span>).<span class="ruby-identifier">execute_single</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_basket" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_basket</span><span
            class="method-args">(session_id)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Fetch the basket of the given session_id.</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>session_id</code> -&gt; A String containing the sessionId of the User</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a
href="AboutYou/SDK/Model/Basket.html">AboutYou::SDK::Model::Basket</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_basket-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 270</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_basket</span>(<span class="ruby-identifier">session_id</span>)
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">fetch_basket</span>(<span class="ruby-identifier">session_id</span>).<span class="ruby-identifier">execute_single</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_categories_by_ids" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_categories_by_ids</span><span
            class="method-args">(ids = nil)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Returns the result of a category search API request. By passing one or
several category ids it will return a result of the categories data.</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>ids</code> -&gt; either a single category ID as integer or an array
of IDs [optional]</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a
href="AboutYou/SDK/Model/CategoriesResult.html">AboutYou::SDK::Model::CategoriesResult</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_categories_by_ids-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 285</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_categories_by_ids</span>(<span class="ruby-identifier">ids</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-comment"># we allow to pass a single ID instead of an array</span>
  <span class="ruby-identifier">ids</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">ids</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">ids</span>

  <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">CategoriesResult</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">category_manager</span>, <span class="ruby-identifier">ids</span>)
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_category_tree" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_category_tree</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Fetches the Root Categories of the Category Tree</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a
href="AboutYou/SDK/Model/CategoryTree.html">AboutYou::SDK::Model::CategoryTree</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_category_tree-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 298</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_category_tree</span>
  <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">CategoryTree</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">category_manager</span>)
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_child_apps" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_child_apps</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Returns the list of child apps</p>
<ul><li>
<p><strong>returns</strong>  :</p>
<ul><li>
<p>an Array containing all child Apps</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_child_apps-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 473</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_child_apps</span>
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">fetch_child_apps</span>.<span class="ruby-identifier">execute_single</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_facet" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_facet</span><span
            class="method-args">(params)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Fetch single facets by id and group id</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>params</code> -&gt; Hash containing 2 keys: "id", "group_id"</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p><a href="AboutYou/SDK/Model/Facet.html">AboutYou::SDK::Model::Facet</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_facet-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 448</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_facet</span>(<span class="ruby-identifier">params</span>)
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">fetch_facet</span>(<span class="ruby-identifier">params</span>).<span class="ruby-identifier">execute_single</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_facet_types" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_facet_types</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Fetches all possible Facet types</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Array with all group ids</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_facet_types-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 422</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_facet_types</span>
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">fetch_facet_types</span>.<span class="ruby-identifier">execute_single</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_facets" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_facets</span><span
            class="method-args">(group_ids = [])</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Fetch the facets of the given group_ids</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>group_ids</code> -&gt; Array of group ids [optional]</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a
href="AboutYou/SDK/Model/Facet.html">AboutYou::SDK::Model::Facet</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_facets-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 409</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_facets</span>(<span class="ruby-identifier">group_ids</span> = [])
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">model_factory_instance</span>.<span class="ruby-identifier">facet_manager</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">query</span>.<span class="ruby-identifier">fetch_facets</span>.<span class="ruby-identifier">execute_single</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">model_factory_instance</span>.<span class="ruby-identifier">facet_manager</span>.<span class="ruby-identifier">facets_by_group_ids</span>(<span class="ruby-identifier">group_ids</span>)
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_order" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_order</span><span
            class="method-args">(order_id)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>fetches Order for specific id</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>orderId</code> -&gt; The id for which an order should be returned</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a
href="AboutYou/SDK/Model/Order.html">AboutYou::SDK::Model::Order</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_order-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 435</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_order</span>(<span class="ruby-identifier">order_id</span>)
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">fetch_order</span>(<span class="ruby-identifier">order_id</span>).<span class="ruby-identifier">execute_single</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_product_search" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_product_search</span><span
            class="method-args">(criteria)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Fetches the response for a product search</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>criteria</code> -&gt; Hash containing one or multiple search terms</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a
href="AboutYou/SDK/Model/ProductSearchResult.html">AboutYou::SDK::Model::ProductSearchResult</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_product_search-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 396</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_product_search</span>(<span class="ruby-identifier">criteria</span>)
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">fetch_product_search</span>(<span class="ruby-identifier">criteria</span>).<span class="ruby-identifier">execute_single</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_products_by_eans" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_products_by_eans</span><span
            class="method-args">(eans, fields = [])</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Fetches products for specific eans</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>eans</code> -&gt; Either a single ean or an Array of eans which
should be fetched</p>
</li><li>
<p><code>fields</code> -&gt; Additional product fields which should be fetched
for each product [optional]</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of AboutYou::SDK::Model::ProductsEanResult</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_products_by_eans-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 380</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_products_by_eans</span>(<span class="ruby-identifier">eans</span>, <span class="ruby-identifier">fields</span> = [])
  <span class="ruby-comment"># we allow to pass a single ID instead of an array</span>
  <span class="ruby-identifier">eans</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">eans</span>)

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">fetch_products_by_eans</span>(<span class="ruby-identifier">eans</span>, <span class="ruby-identifier">fields</span>).<span class="ruby-identifier">execute_single</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_products_by_ids" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_products_by_ids</span><span
            class="method-args">(ids, fields = [])</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Fetches the products for specific ids</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>ids</code> -&gt; Either a single id or an Array of ids which should
be fetched</p>
</li><li>
<p><code>fields</code> -&gt; Additional product fields which should be fetched
for each product [optional]</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a
href="AboutYou/SDK/Model/ProductsResult.html">AboutYou::SDK::Model::ProductsResult</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_products_by_ids-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 331</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_products_by_ids</span>(<span class="ruby-identifier">ids</span>, <span class="ruby-identifier">fields</span> = [])
  <span class="ruby-comment"># we allow to pass a single ID instead of an array</span>
  <span class="ruby-identifier">ids</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">ids</span>)
  <span class="ruby-identifier">result</span> = <span class="ruby-identifier">query</span>.<span class="ruby-identifier">fetch_products_by_ids</span>(<span class="ruby-identifier">ids</span>, <span class="ruby-identifier">fields</span>).<span class="ruby-identifier">execute_single</span>
  <span class="ruby-identifier">products_not_found</span> = <span class="ruby-identifier">result</span>.<span class="ruby-identifier">products_not_found</span>

  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">products_not_found</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">logger</span>
    <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">warning</span>(<span class="ruby-string">'products not found: appid='</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">app_id</span> <span class="ruby-operator">+</span>
        <span class="ruby-string">' product ids=['</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">products_not_found</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">','</span>) <span class="ruby-operator">+</span> <span class="ruby-string">']'</span>
    )
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_spell_correction" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_spell_correction</span><span
            class="method-args">(searchword, category_ids = nil)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Returns the result of an spell correction API request. spell correction
searches for products by a given searchword. You might filter by category
ids aswell.</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>searchword</code> -&gt; The prefix search word to search for</p>
</li><li>
<p><code>category_ids</code> -&gt; The category ids used as a filter
[optional]</p>
</li></ul>
</li><li>
<p><strong>Fails</strong> :</p>
<ul><li>
<p>if a category id cant be transformed into an Integer</p>
</li><li>
<p>if a category id is smaller then 1</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Array of Strings</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_spell_correction-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 245</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_spell_correction</span>(<span class="ruby-identifier">searchword</span>, <span class="ruby-identifier">category_ids</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">category_ids</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-comment"># we allow to pass a single ID instead of an array</span>
    <span class="ruby-identifier">category_ids</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">category_ids</span>)

    <span class="ruby-identifier">category_ids</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cat_id</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">fail</span> <span class="ruby-string">'InvalidArgumentException! A single category ID must be an integer
        or a numeric string'</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">cat_id</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Integer</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">cat_id</span>[<span class="ruby-regexp">/\d/</span>]
      <span class="ruby-identifier">fail</span> <span class="ruby-string">'\InvalidArgumentException! A single category ID must be greater
        than 0'</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">cat_id</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">1</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">fetch_spell_correction</span>(<span class="ruby-identifier">searchword</span>, <span class="ruby-identifier">category_ids</span>).<span class="ruby-identifier">execute_single</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_suggest" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_suggest</span><span
            class="method-args">(searchword)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Returns the result of a suggest API request. Suggestions are words that are
often searched together with the searchword you pass (e.g. “stretch” for
“jeans”).</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>searchword</code> -&gt; The search string to search for</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>an Array containing the suggestions</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_suggest-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 463</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_suggest</span>(<span class="ruby-identifier">searchword</span>)
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">fetch_suggest</span>(<span class="ruby-identifier">searchword</span>).<span class="ruby-identifier">execute_single</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_variants_by_ids" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_variants_by_ids</span><span
            class="method-args">(ids)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Fetches variants for specific ids</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>ids</code> -&gt; Either a single id or an Array of ids which should
be fetched</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a
href="AboutYou/SDK/Model/VariantsResult.html">AboutYou::SDK::Model::VariantsResult</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_variants_by_ids-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 355</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_variants_by_ids</span>(<span class="ruby-identifier">ids</span>)
  <span class="ruby-comment"># we allow to pass a single ID instead of an array</span>
  <span class="ruby-identifier">ids</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">ids</span>)
  <span class="ruby-identifier">result</span> = <span class="ruby-identifier">query</span>.<span class="ruby-identifier">fetch_live_variant_by_ids</span>(<span class="ruby-identifier">ids</span>).<span class="ruby-identifier">execute_single</span>
  <span class="ruby-identifier">variants_not_found</span> = <span class="ruby-identifier">result</span>.<span class="ruby-identifier">variants_not_found</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">variants_not_found?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">logger</span>
    <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">warning</span>(<span class="ruby-string">'variants or products for variants not found: appid='</span> <span class="ruby-operator">+</span>
        <span class="ruby-identifier">app_id</span> <span class="ruby-operator">+</span> <span class="ruby-string">' variant ids=['</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">variants_not_found</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">','</span>) <span class="ruby-operator">+</span> <span class="ruby-string">']'</span>
    )
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-generate_basket_item_id" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">generate_basket_item_id</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Method to create a unique item id for items in basket</p>
<ul><li>
<p><strong>Args</strong>    :</p>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>an Intger</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="generate_basket_item_id-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 149</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">generate_basket_item_id</span>
  <span class="ruby-string">'i_'</span> <span class="ruby-operator">+</span> <span class="ruby-constant">SecureRandom</span>.<span class="ruby-identifier">uuid</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-init_default_factory" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">init_default_factory</span><span
            class="method-args">(cache = nil)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>initializes the default model factory</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>cache</code> -&gt; an Instance of the used cache [optional]</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="init_default_factory-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 590</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">init_default_factory</span>(<span class="ruby-identifier">cache</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">model_factory_instance</span> = <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Factory</span><span class="ruby-operator">::</span><span class="ruby-constant">DefaultModelFactory</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>)

  <span class="ruby-identifier">model_factory_instance</span>.<span class="ruby-identifier">initialize_managers</span>(
    <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">FacetManager</span><span class="ruby-operator">::</span><span class="ruby-constant">DefaultFacetManager</span>.<span class="ruby-identifier">new</span>(
      <span class="ruby-identifier">cache</span>,
      <span class="ruby-identifier">app_id</span>,
      <span class="ruby-keyword">self</span>
    ),
    <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">CategoryManager</span><span class="ruby-operator">::</span><span class="ruby-constant">DefaultCategoryManager</span>.<span class="ruby-identifier">new</span>(
      <span class="ruby-identifier">cache</span>,
      <span class="ruby-identifier">app_id</span>,
      <span class="ruby-keyword">self</span>
    )
  )
  <span class="ruby-identifier">model_factory_instance</span>.<span class="ruby-identifier">base_image_url</span> = <span class="ruby-identifier">base_image_url</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-initiate_order" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">initiate_order</span><span
            class="method-args">(session_id, success_url, cancel_url = nil, error_url = nil)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Method to initiaite the order</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>session_id</code> -&gt; A String containing the sessionId of the User</p>
</li><li>
<p><code>successUrl</code> -&gt; callback URL if the order was OK</p>
</li><li>
<p><code>cancelUrl</code> -&gt; callback URL if the order was canceled
[optional]</p>
</li><li>
<p><code>errorUrl</code> -&gt; callback URL if the order had any exceptions
[optional]</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a
href="AboutYou/SDK/Model/InitiateOrder.html">AboutYou::SDK::Model::InitiateOrder</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="initiate_order-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 196</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initiate_order</span>(<span class="ruby-identifier">session_id</span>, <span class="ruby-identifier">success_url</span>, <span class="ruby-identifier">cancel_url</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">error_url</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">initiate_order</span>(
    <span class="ruby-identifier">session_id</span>,
    <span class="ruby-identifier">success_url</span>,
    <span class="ruby-identifier">cancel_url</span>,
    <span class="ruby-identifier">error_url</span>
  ).<span class="ruby-identifier">execute_single</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-java_script_tag" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">java_script_tag</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Returns a HTML script tag that loads the Collins JavaScript fie.</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>a string containing an HTML script tag</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="java_script_tag-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 538</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">java_script_tag</span>
  <span class="ruby-string">'&lt;script type=&quot;text/javascript&quot; src=&quot;'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">java_script_url</span> <span class="ruby-operator">+</span> <span class="ruby-string">'&quot;&gt;&lt;/script&gt;'</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-java_script_url" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">java_script_url</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Returns the URL to the Collins JavaScript file for helper functions to add
product variants into the basket of ABOUT YOU or auto-resizing the iframe.
This URL may be changed in future, so please use this method instead of a
hard coded URL into your HTML template.</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>a string containing an url to the javascript file</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="java_script_url-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 523</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">java_script_url</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">environment</span> <span class="ruby-operator">==</span> <span class="ruby-constant">API_ENVIRONMENT_STAGE</span>
    <span class="ruby-string">'//devcenter-staging-www1.pub.collins.kg:81/appjs/'</span> <span class="ruby-operator">+</span>
      <span class="ruby-constant">String</span>(<span class="ruby-identifier">app_id</span>) <span class="ruby-operator">+</span> <span class="ruby-string">'.js'</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-string">'//developer.aboutyou.de/appjs/'</span> <span class="ruby-operator">+</span> <span class="ruby-constant">String</span>(<span class="ruby-identifier">app_id</span>) <span class="ruby-operator">+</span> <span class="ruby-string">'.js'</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-model_factory" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">model_factory</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Method for getting the model factory. If no model factory is set it
initializes the default one</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>an Instance of <a
href="AboutYou/SDK/Factory/DefaultModelFactory.html">AboutYou::SDK::Factory::DefaultModelFactory</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="model_factory-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 493</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">model_factory</span>
  <span class="ruby-identifier">init_default_factory</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">model_factory_instance</span>

  <span class="ruby-identifier">model_factory_instance</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-product_search_criteria" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">product_search_criteria</span><span
            class="method-args">(session_id = nil)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Method for getting the product search criteria base class, on which you can
specify your criteria</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>session_id</code> -&gt; a string containing the session id [optional]</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p><a
href="AboutYou/SDK/Criteria/ProductSearchCriteria.html">AboutYou::SDK::Criteria::ProductSearchCriteria</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="product_search_criteria-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 508</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">product_search_criteria</span>(<span class="ruby-identifier">session_id</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">session_id</span>  = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">session_id</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">session_id</span>

  <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Criteria</span><span class="ruby-operator">::</span><span class="ruby-constant">ProductSearchCriteria</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">session_id</span>)
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-query" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">query</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Method for getting the query</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>an Instance of <a href="AboutYou/SDK/Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="query-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 483</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">query</span>
  <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Query</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">about_you_client</span>, <span class="ruby-identifier">model_factory</span>)
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-remove_items_from_basket" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">remove_items_from_basket</span><span
            class="method-args">(session_id, item_ids)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Method to remove items from basket</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>session_id</code> -&gt; A String containing the sessionId of the User</p>
</li><li>
<p><code>itemIds</code> -&gt; an Array of Item ids which should be removed</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a
href="AboutYou/SDK/Model/Basket.html">AboutYou::SDK::Model::Basket</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="remove_items_from_basket-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 163</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">remove_items_from_basket</span>(<span class="ruby-identifier">session_id</span>, <span class="ruby-identifier">item_ids</span>)
  <span class="ruby-identifier">basket</span> = <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">Basket</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">basket</span>.<span class="ruby-identifier">delete_items</span>(<span class="ruby-identifier">item_ids</span>)

  <span class="ruby-identifier">update_basket</span>(<span class="ruby-identifier">session_id</span>, <span class="ruby-identifier">basket</span>)
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-update_basket" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">update_basket</span><span
            class="method-args">(session_id, basket)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Method to update a given basket</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>session_id</code> -&gt; A String containing the sessionId of the User</p>
</li><li>
<p><code>basket</code> -&gt; an Instance of a basket</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a
href="AboutYou/SDK/Model/Basket.html">AboutYou::SDK::Model::Basket</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="update_basket-source">
            <pre><span class="ruby-comment"># File lib/aboutyou-sdk.rb, line 180</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">update_basket</span>(<span class="ruby-identifier">session_id</span>, <span class="ruby-identifier">basket</span>)
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">update_basket</span>(<span class="ruby-identifier">session_id</span>, <span class="ruby-identifier">basket</span>).<span class="ruby-identifier">execute_single</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
  </section>
</main>


<footer id="validator-badges" role="contentinfo">
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
  <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.2.
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>

